package com.srit.forecast.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.srit.forecast.controller.vo.City6HoursVO;
import com.srit.forecast.service.City6HoursService;
import com.srit.system.bean.CodeType;
import com.srit.system.bean.EffectTimeGroup;
import com.srit.system.dao.CodeTypeDao;
import com.srit.system.dao.EffectTimeGroupDao;

@Controller
public class City6HoursController {
	@Autowired
	private CodeTypeDao codeTypeDao;
	@Autowired
	private City6HoursService city6HoursService;
	@Autowired
	private EffectTimeGroupDao effectTimeGroupDao;

	@RequestMapping(value = "/city6Hours-form")
	public String form(@ModelAttribute City6HoursVO city6HoursVO,
			ModelMap modelMap) {
		List<CodeType> codeTypeList = codeTypeDao.listOnDrag();// 暂时所有的
		modelMap.addAttribute("codeTypeList", codeTypeList);
		EffectTimeGroup effectTimeGroup = effectTimeGroupDao.getById(27);
		modelMap.addAttribute("effectTimeGroup", effectTimeGroup);
		return "city6Hours";
	}

	@RequestMapping(value = "/city6Hours-save", method = RequestMethod.POST)
	public String save(City6HoursVO city6HoursVO) {
		System.out.println(city6HoursVO);
		city6HoursService.doReport(city6HoursVO);
		return "redirect:/city6Hours-form";
	}
}
